package com.singletonapps.evory.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Version;

import com.singletonapps.evory.dto.CourseTemaDto;

@Entity
@Table(name = "COURSE_TEMA")
public class CourseTema implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5229126687236912179L;

	@Id
	@SequenceGenerator(name="course_tema_seq", sequenceName="SEQ_COURSE_TEMA_ID", allocationSize=1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "course_tema_seq")
	@Column(name = "id")
	private Long id;
	
	@ManyToOne
	@JoinColumn(name = "COURSE_ID")
	private Course curso;
	
	@Column(name = "TEMA_NAME")
	private String nombreTema;
	
	@Column(name = "TEMA_DESC")
	private String descTema;
	
	@Column(name = "DATE_CREATE", nullable = false)
	private Date dateCreated;
	
	@Column(name = "DATE_UPDATE")
	private Date dateUpdated;
	
	@Version
	private int version;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Course getCurso() {
		return curso;
	}

	public void setCurso(Course curso) {
		this.curso = curso;
	}

	public String getNombreTema() {
		return nombreTema;
	}

	public void setNombreTema(String nombreTema) {
		this.nombreTema = nombreTema;
	}

	public String getDescTema() {
		return descTema;
	}

	public void setDescTema(String descTema) {
		this.descTema = descTema;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateUpdated() {
		return dateUpdated;
	}

	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}

	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}
	
	public CourseTemaDto toDto(){
		CourseTemaDto dto = new CourseTemaDto();
		
		dto.setId(this.id);
		//dto.setCurso(this.curso.toDto());
		dto.setNombreTema(this.nombreTema);
		dto.setDescTema(this.descTema);
		dto.setDateCreated(this.dateCreated);
		dto.setDateUpdated(this.dateUpdated);
		dto.setVersion(this.version);
		
		return dto;
	}
	
}
